package com.example.application;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class IntentDemoActivity extends AppCompatActivity {
    private int timesGet;
    private TextView clickTimes;
    private Button back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intent_demo);
        Intent intent = getIntent();
        timesGet = intent.getIntExtra("times", 0);
        clickTimes = findViewById(R.id.show_times);
        clickTimes.setText("" + timesGet);
        back = findViewById(R.id.btn_back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(IntentDemoActivity.this, MainActivity.class);
                i.putExtra("cTimes", timesGet);
                startActivity(i);
                finish();
            }
        });
    }
}
